#include "hal.h"
#include "dbg_tool.h"

static void on_can_rx_ready(const U8 bus_id, can_frame_t* frame)
{
    trace_info("[CAN%d]:MSG ID %d size %d\r\n", bus_id, frame->id, frame->len);
    trace_buffer(frame->data, frame->len);
}

/**
 *@brief main function
 */
int main(void)
{
    /* Initiate the HAL libraries */
    hal_init();
    hal_can_init(HAL_CAN0);
    
    hal_can_reg_rx_ready(HAL_CAN0, on_can_rx_ready);
      
    while (1)
    {
        /* toggle LED1 */
        hal_led_toggle(HAL_LED0);
        hal_delay_ms(500);
        hal_can_transmit(0, 123+65536, "12345678", 8);
    }
}
